package com.cskt.petproject178.controller;

import com.cskt.petproject178.pojo.param.SearchProductParam;
import com.cskt.petproject178.pojo.vo.PageVO;
import com.cskt.petproject178.pojo.vo.ResultVO;
import com.cskt.petproject178.pojo.vo.SearchProductVO;
import com.cskt.petproject178.pojo.vo.SpusVO;
import com.cskt.petproject178.service.ProductParamService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * 商品控制器
 *
 * @author 27013
 **/

@RestController
@RequestMapping(value = "/pms/product")
public class ProductParamController {
    @Resource
    private ProductParamService productParamService;

    @PostMapping(value = "/search")
    public ResultVO<PageVO<SearchProductVO>>  search(@RequestBody SearchProductParam param){
        PageVO<SearchProductVO> searchProductVOByParam = productParamService.getSearchProductVOByParam(param);
        return ResultVO.OK(searchProductVOByParam);
    }

    @GetMapping(value = "/detail")
    public ResultVO<SpusVO> detail(@RequestParam(value = "spuId") Long spuId){
        SpusVO supsVO = productParamService.getSupsvoById(spuId);
        return ResultVO.OK(supsVO);
    }
}
